<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <title>微赢智能信息管理系统</title>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <!-- VENDOR CSS -->
    <link rel="stylesheet" th:href="@{/assets/vendor/bootstrap/css/bootstrap.min.css}">
    <link rel="stylesheet" th:href="@{/assets/vendor/font-awesome/css/font-awesome.min.css}">
    <link rel="stylesheet" th:href="@{/assets/vendor/linearicons/style.css}">
    <link rel="stylesheet" th:href="@{/assets/vendor/chartist/css/chartist-custom.css}">
    <!-- MAIN CSS -->
    <link rel="stylesheet" th:href="@{/assets/css/main.css}">
    <!-- FOR DEMO PURPOSES ONLY. You should remove this in your project -->
    <link rel="stylesheet" th:href="@{/assets/css/demo.css}">
    <!-- ICONS -->
    <link rel="apple-touch-icon" sizes="76x76" th:href="@{/assets/img/apple-icon.png}">
    <link rel="icon" type="image/png" sizes="96x96" th:href="@{/assets/img/favicon.png}">
    <script th:src="@{/assets/vendor/jquery/jquery.min.js}"></script>
    <script th:src="@{/assets/vendor/bootstrap/js/bootstrap.min.js}"></script>
    <script th:src="@{/assets/vendor/jquery-slimscroll/jquery.slimscroll.min.js}"></script>
    <script th:src="@{/assets/vendor/jquery.easy-pie-chart/jquery.easypiechart.min.js}"></script>
    <script th:src="@{/assets/vendor/chartist/js/chartist.min.js}"></script>
    <script th:src="@{/assets/scripts/klorofil-common.js}"></script>
    <link rel="stylesheet" th:href="@{/assets/bootstrap-table/bootstrap-table.css}">
    <script th:src="@{/assets/bootstrap-table/bootstrap-table.js}"></script>
    <script th:src="@{/assets/bootstrap-table/bootstrap-table-filter-control.js}"></script>
    <script th:src="@{/assets/bootstrap-table/bootstrap-table-zh-CN.js}"></script>
    <script th:src="@{/assets/bootstrap-table/bootstrap-table-fixed-columns.js}"></script>
    <link rel="stylesheet" th:href="@{/assets/bootstrap-table/bootstrap-editable.css}">
    <script th:src="@{/assets/bootstrap-table/bootstrap-editable.js}"></script>
    <script th:src="@{/assets/bootstrap-table/bootstrap-table-editable.js}"></script>
    <script th:src="@{/assets/layer/laydate.js}"></script>
    <script th:src="@{/assets/layer/layer.js}"></script>
    <style>
        .questionInfo-input {
            border-left: 0px;
            border-top: 0px;
            border-right: 0px;
            border-bottom: 1px
        }

        .questionInfo-textArea {
            overflow: auto;
            background-attachment: fixed;
            background-repeat: no-repeat;
            border-style: solid;
            border-color: #FFFFFF;
        }
    </style>
</head>
<body>
<!-- WRAPPER -->
<div id="wrapper">
    <!-- NAVBAR -->
    <nav class="navbar navbar-default navbar-fixed-top">
        <div class="brand">
            <a th:href="@{/index}" href="index.html"><img th:src="@{/assets/img/logo-dark.png}" alt="Klorofil Logo"
                                                          class="img-responsive logo"></a>
        </div>
        <div class="container-fluid">
            <div class="navbar-btn">
                <button type="button" class="btn-toggle-fullwidth"><i class="lnr lnr-arrow-left-circle"></i></button>
            </div>
            <div id="navbar-menu">
                <ul class="nav navbar-nav navbar-right">
                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown"><img th:src="@{/assets/img/user.png}"
                                                                                        class="img-circle" alt="Avatar">
                            <span th:text="${session.loginSysUserName}">Samuel</span> <i
                                    class="icon-submenu lnr lnr-chevron-down"></i></a>
                        <ul class="dropdown-menu">
                            <li><a th:href="@{/logout}"><i class="lnr lnr-exit"></i> <span>退出</span></a></li>
                        </ul>
                    </li>
                    <!-- <li>
                        <a class="update-pro" href="#downloads/klorofil-pro-bootstrap-admin-dashboard-template/?utm_source=klorofil&utm_medium=template&utm_campaign=KlorofilPro" title="Upgrade to Pro" target="_blank"><i class="fa fa-rocket"></i> <span>UPGRADE TO PRO</span></a>
                    </li> -->
                </ul>
            </div>
        </div>
    </nav>
    <!-- END NAVBAR -->
    <!-- LEFT SIDEBAR -->
    <div id="sidebar-nav" class="sidebar">
        <div class="sidebar-scroll">
            <nav>
                <ul class="nav">
                    <shiro:hasPermission name="jggl">
                        <li>
                            <a href="#subPages1" data-toggle="collapse" class="collapsed "><i
                                    class="lnr lnr-apartment"></i>
                                <span>机构管理</span> <i class="icon-submenu lnr lnr-chevron-left"></i></a>
                            <div id="subPages1" class="collapse">
                                <ul class="nav">
                                    <shiro:hasPermission name="jgxxgl">
                                        <li><a th:href="@{/hospital}">
                                            <span>机构信息管理</span></a>
                                        </li>
                                    </shiro:hasPermission>
                                    <shiro:hasPermission name="tp">
                                        <li><a th:href="@{/images}" class=""> <span>图片</span></a>
                                        </li>
                                    </shiro:hasPermission>
                                    <shiro:hasPermission name="jgflgl">
                                        <li><a th:href="@{/hospitalField}" class="">
                                            <span>机构分类管理</span></a></li>
                                    </shiro:hasPermission>
                                    <shiro:hasPermission name="bmgl">
                                        <li><a th:href="@{/hospitalDepartment}" class="">
                                            <span>部门管理</span></a></li>
                                    </shiro:hasPermission>
                                    <shiro:hasPermission name="jgjjgl">
                                        <li><a th:href="@{/hospitalProfile}" class="">
                                            <span>机构简介管理</span></a></li>
                                    </shiro:hasPermission>
                                </ul>
                            </div>
                        </li>
                    </shiro:hasPermission>
                    <shiro:hasPermission name="qxgl">
                        <li><a th:href="@{/hospitalPermission}" class=""><i class="lnr lnr-inbox"></i>
                            <span>权限管理</span></a></li>
                    </shiro:hasPermission>
                    <!--  <li><a th:href="@{/user}" class=""><i class="lnr lnr-users"></i>
                          <span>用户管理</span></a></li>-->
                    <shiro:hasPermission name="zjgl">
                        <li>
                            <a href="#subPages" data-toggle="collapse" class="collapsed"><i
                                    class="lnr lnr-graduation-hat"></i>
                                <span>专家管理</span> <i class="icon-submenu lnr lnr-chevron-left"></i></a>
                            <div id="subPages" class="collapse ">
                                <ul class="nav">
                                    <shiro:hasPermission name="zjxxgl">
                                        <li><a th:href="@{/master}" class="">专家信息管理</a></li>
                                    </shiro:hasPermission>
                                    <shiro:hasPermission name="zjdtmx">
                                        <li><a th:href="@{/masterScore}" class="">专家答题明细</a>
                                        </li>
                                    </shiro:hasPermission>
                                </ul>
                            </div>
                        </li>
                    </shiro:hasPermission>
                    <shiro:hasPermission name="wtgl">
                        <li><a th:href="@{/question}" class=""><i class="lnr lnr-menu-circle"></i>
                            <span>问题管理</span></a></li>
                    </shiro:hasPermission>
                    <shiro:hasPermission name="hmd">
                        <li><a th:href="@{/blackList}" class=""><i class="lnr lnr-sad"></i> <span>黑名单</span></a>
                        </li>
                    </shiro:hasPermission>
                    <shiro:hasPermission name="dd">
                        <li><a th:href="@{/wxOrder}" class=""><i class="lnr lnr-list"></i> <span>订单</span></a></li>
                    </shiro:hasPermission>
                    <shiro:hasPermission name="yhhdgl">
                        <li><a th:href="@{/hospitalActivity}" class=""><i class="lnr lnr-star"></i>
                            <span>优惠活动管理</span></a>
                        </li>
                    </shiro:hasPermission>
                    <shiro:hasPermission name="ztjz">
                        <li><a th:href="@{/knowledge}" class=""><i class="lnr lnr-diamond"></i> <span>专题讲座</span></a>
                        </li>
                    </shiro:hasPermission>
                    <shiro:hasPermission name="yygl">
                        <li>
                            <a href="#subPages2" data-toggle="collapse" class="collapsed"><i
                                    class="lnr lnr-pencil"></i>
                                <span>预约管理</span> <i class="icon-submenu lnr lnr-chevron-left"></i></a>
                            <div id="subPages2" class="collapse ">
                                <ul class="nav">
                                    <shiro:hasPermission name="yyslgl">
                                        <li><a th:href="@{/guahao}" class="">预约数量管理</a></li>
                                    </shiro:hasPermission>
                                    <shiro:hasPermission name="xxgl">
                                        <li><a th:href="@{/hospitalSchedule}" class="">信息管理</a></li>
                                    </shiro:hasPermission>
                                    <shiro:hasPermission name="lscx">
                                        <li><a th:href="@{/guahaoHistory}" class="">历史查询</a>
                                        </li>
                                    </shiro:hasPermission>
                                </ul>
                            </div>
                        </li>
                    </shiro:hasPermission>
                </ul>
            </nav>
        </div>
    </div>
    <div class="main">
        <!-- MAIN CONTENT -->
        <div class="main-content">
            <div class="container-fluid">
                <div class="row">
                    <div id="search-form" class="form-inline" role="form" style="margin-bottom: -5px">
                        <div class="form-group">
                            <label>问题内容：</label>
                            <input type="text" class="form-control" id="questionContent"
                                   style="width: 360px;margin-left: 30px"
                                   name="questionContent"
                                   placeholder="问题内容">
                        </div>
                        <div class="form-group">
                            <label>问题分类：</label>
                            <select id="questionClass" name="questionClass" style="width: 160px" class="form-control">
                                <option value=""></option>
                                <option th:each="qClass: ${questionClass}"
                                        th:value="${qClass}" th:text="${qClass}">
                                </option>
                            </select>
                        </div>
                        <div class="form-group">
                            <label style="margin-left: 33px">是否已经解决:</label>
                            <select id="isSolved" name="isSolved" class="form-control">
                                <option value=""></option>
                                <option value="是">是</option>
                                <option value="否">否
                                <option value="已关闭">已关闭</option>
                            </select>
                        </div>
                        <div class="form-group">
                            <label>所属机构名称：</label>
                            <select id="hospitalName" name="hospitalName" style="width: 360px" class="form-control">
                                <option value=""></option>
                                <option th:each="hospital : ${hospitals}"
                                        th:value="${hospital.name}" th:text="${hospital.name}">Credit
                                    card
                                </option>
                            </select>
                        </div>
                        <div class="form-group">
                            <label>提问日期：</label>
                            <input type="text" id="startDate" class="form-control"
                                   style="width: 160px;"
                                   placeholder="开始日期"> ——
                            <input type="text" id="endDate" class="form-control" style="width: 185px"
                                   placeholder="结束日期">
                        </div>
                        <div class="form-group">
                            <label>提问者姓名：</label>
                            <input type="text" class="form-control" id="userName" style="width: 206px;margin-left: 15px"
                                   name="userName"
                                   placeholder="提问者姓名">
                        </div>
                        <div class="form-group" style="margin-left: 10px">
                            <label>有无图片：</label>
                            <select id="haveImg" name="haveImg" class="form-control">
                                <option value=""></option>
                                <option value="有">有</option>
                                <option value="无">无</option>
                            </select>
                        </div>
                        <div class="form-group">
                            <label>价格：</label>
                            <input type="text" class="form-control" id="questionMoney"
                                   style="width: 62px;margin-left: 28px"
                                   name="questionMoney"
                                   placeholder="价格">
                        </div>
                        <div class="form-group" style="margin-left: 133px;">
                            <label>是否过期：</label>
                            <select id="answerStatus" name="answerStatus" class="form-control" style="width:107px;">
                                <option value=""></option>
                                <option value="是">是</option>
                                <option value="否">否</option>
                            </select>
                        </div>
                        <button id="btn-search" type="button" onclick="search()"
                                class="btn btn-info btn-sm rightSize" style="margin-left: 1px">
                            <span class="glyphicon glyphicon-search" aria-hidden="true"></span>搜索
                        </button>
                    </div>
                </div>
                <div class="row">
                    <table id="hospital-table">
                    </table>
                    <!-- END MAIN CONTENT -->
                </div>
            </div>
        </div>
    </div>
</div>
<!-- 模态框（Modal） -->
<div class="modal fade" id="img-model" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-body" id="img-content">
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div>
<div class="modal fade" id="lookImg-model" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
     aria-hidden="true">
    <div class="modal-dialog" style="width: 530px;height: 600px">
        <div class="modal-content">
            <div class="modal-body">
                <img id="lookImg-content" style="width:500px;height: 600px" src="">
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div>
<div class="modal fade" id="questionInfo-model" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
     aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-body">
                <div style=" border:2px solid #000">
                    <p id="questionInfo-isSolved" style="text-align: center;color: red;"></p>
                    <label>机构名称:</label>
                    <input id="questionInfo-hospitalName" class="questionInfo-input" readonly>
                    <label>提问者姓名:</label>
                    <input id="questionInfo-userName" class="questionInfo-input" readonly>
                    <label>问题分类:</label>
                    <input id="questionInfo-questionClass" class="questionInfo-input" readonly>
                    <label>提问时间:</label>
                    <input id="questionInfo-createDate" class="questionInfo-input" readonly>
                    <div>
                        <label>价格:</label>
                        <input id="questionInfo-money" class="questionInfo-input" readonly>
                    </div>
                    <div><label>问题内容:</label></div>
                    <textArea id="questionInfo-questionContent" class="questionInfo-textArea"
                              style="width: 550px;height: 100px" readonly></textArea>
                    <label>图片:</label>
                    <div id="questionInfo-img"></div>
                </div>
                <p style="text-align: center;color: red;margin-top: 50px">回答情况</p>
                <div id="answerInfo" style="margin-top: 30px; ">
                </div>
            </div>
            <div class="modal-footer">
                <shiro:hasPermission name="answerQuestionBtn">
                    <button type="button" class="btn btn-primary" onclick="answerQuestionModel()">回答</button>
                </shiro:hasPermission>
                <button type="button" class="btn btn-default" onclick="closeQuestionInfoModel()">关闭</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div>
<div class="modal fade" id="questionImgModel" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
     aria-hidden="true">
    <div class="modal-dialog" style="width: 530px;height: 600px;">
        <div class="modal-content">
            <div class="modal-body">
                <img id="questionImg" src="" style="width:500px;height: 600px">
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" onclick="closeQuestionImgModel()">关闭</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div>
<div class="modal fade" id="answerImgModel" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
     aria-hidden="true">
    <div class="modal-dialog" style="width: 530px;height: 600px;">
        <div class="modal-content">
            <div class="modal-body">
                <img id="answerImg" src="" style="width:500px;height: 600px">
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div>
<div class="modal fade" id="model2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-body" style="text-align: center"><h2>确定将问题删除？</h2></div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" onclick="addUserBlack()">确定</button>
                <button type="button" class="btn btn-default" onclick="modelhide2()">关闭</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div>
<div class="modal fade" id="answerContentModel" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
     aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-body" id="answerContent">
                <form role="form" id="answerForm">
                    <input type="text" class="form-control" id="answerContentQuestion" name="answerContentQuestion"
                           style="display: none">
                    <div class="form-group">
                        <label>回答内容</label>
                        <textArea id="answerContentText" name="answerContentText" class="form-control"
                                  style="width: 550px;height: 100px"></textArea>
                    </div>
                    <div class="form-group">
                        <label>图片1</label>
                        <input name="answerContentImg" class="form-control" type="file"></input>
                    </div>
                    <div class="form-group">
                        <label>图片2</label>
                        <input name="answerContentImg" class="form-control" type="file"></input>
                    </div>
                    <div class="form-group">
                        <label>图片3</label>
                        <input name="answerContentImg" class="form-control" type="file"></input>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" onclick="addAnswerContentModel()">提交</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div>
<div class="modal fade" id="model3" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-body" style="text-align: center"><h2>请先选择要回答的问题</h2></div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div>
<div class="modal fade" id="model4" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-body" style="text-align: center"><h2>问题已过期，无法回答</h2></div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div>
<div class="modal fade" id="model5" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-body" style="text-align: center"><h2>确定要提交回答？</h2></div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" onclick="addAnswerContent()">提交</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div>
<div class="modal fade" style="left: 50%;top: 50%;transform: translate(-50%,-50%);" id="loadingModel" tabindex="-1"
     role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog" style="width: 100px; ">
        <div class="modal-content">
            <div class="modal-body" style="vertical-align: middle;text-align: center;">
                <img th:src="@{/assets/img/loadingcircle.gif}">
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div>
<footer>
    <div class="container-fluid">
        <a target="_blank" href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=37078602370880"
           style="display:inline-block;text-decoration:none;height:20px;line-height:20px;"><img
                th:src="@{/assets/img/beian.png}" style="float:left;"/>
            <p style="float:left;height:20px;line-height:20px;margin: 0px 0px 0px 5px; color:#939393;">鲁公网安备
                37078602370880号</p></a>
    </div>
</footer>
<!-- /.modal -->
<!-- END WRAPPER -->
<!-- Javascript -->
<script>
    var modelQuestionId;
    var modelUserId;
    var answerQuestionId;
    $(function () {
        laydate.render({
            elem: '#startDate',//指定元素
            format: 'yyyy-MM-dd HH:mm:ss',
        });
        laydate.render({
            elem: '#endDate',//指定元素
            format: 'yyyy-MM-dd HH:mm:ss',
        });
        //1.初始化Table
        var oTable = new TableInit();
        oTable.Init();
        //2.初始化Button的点击事件
        var oButtonInit = new ButtonInit();
        oButtonInit.Init();
    });
    var TableInit = function () {
        var oTableInit = new Object();
        //初始化Table
        oTableInit.Init = function () {
            $('#hospital-table').bootstrapTable({
                url: '/fenda/findQuestion',         //请求后台的URL（*）
                method: 'get',                      //请求方式（*）
                toolbar: '#toolbar',                //工具按钮用哪个容器
                striped: true,                      //是否显示行间隔色
                cache: false,                       //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
                pagination: true,                     //是否显示分页（*）
                sortable: false,                     //是否启用排序
                sortOrder: "asc",                   //排序方式
                queryParams: oTableInit.queryParams,//传递参数（*）
                sidePagination: "server",           //分页方式：client客户端分页，server服务端分页（*）
                pageNumber: 1,                       //初始化加载第一页，默认第一页
                pageSize: 10,                       //每页的记录行数（*）
                pageList: [10, 20, 30],        //可供选择的每页的行数（*）
                /* search: true, */                      //是否显示表格搜索，此搜索是客户端搜索，不会进服务端，所以，个人感觉意义不大
                strictSearch: false,
                minimumCountColumns: 1,             //最少允许的列数
                clickToSelect: false,                //是否启用点击选中行
                height: document.body.clientHeight,                      //行高，如果没有设置height属性，表格自动根据记录条数觉得表格高度
                uniqueId: "id",                     //每一行的唯一标识，一般为主键列
                cardView: false,                    //是否显示详细视图
                detailView: false,                   //是否显示父子表
                columns: [{
                    field: 'user.hospital.name',
                    align: 'center',
                    valign: "middle",
                    title: '机构名称'
                }, {
                    valign: "middle",
                    width: 60,
                    align: 'center',
                    field: 'user.name',
                    title: '提问者姓名',
                }, {
                    valign: "middle",
                    width: 110,
                    align: 'center',
                    field: 'creatDate',
                    title: '提问时间',
                }, {
                    width: 130,
                    field: 'info',
                    title: '问题内容',
                    align: 'center',
                    valign: "middle",
                    formatter: function (value, row, index) {
                        if ((value.length) == 0 || value == null || value == "") {
                            return "无";
                        } else if (value.length > 10) {
                            return value.substring(0, 10) + "...";
                        } else {
                            return value;
                        }
                    }
                }, {
                    align: 'center',
                    valign: "middle",
                    field: 'questionURLSet',
                    title: '图片',
                    width: 200,
                    formatter: function (value, row, index) {
                        if ((value.length) == 0 || value == null || value == "") {
                            return "无";
                        } else {
                            var imgValue = "";
                            $(value).each(function (index, element) {
                                imgValue += "<img src='" + element.imgURL + "' style='width:50px;height: 50px;margin-right: 5px' onclick=\"foundImg('" + element.imgURL + "')\">";
                            });
                            return imgValue;
                        }
                        /*return '<div><button  type="button" class="btn btn-default btn-toastr-callback" onclick="openImg(' + row.id + ')">查看</button></div>';*/
                    }
                }, {
                    align: 'center',
                    valign: "middle",
                    width: 60,
                    field: 'questionClass',
                    title: '问题分类',
                }, {
                    align: 'center',
                    valign: "middle",
                    field: 'wxOrder.money',
                    title: '价格',
                }, {
                    align: 'center',
                    valign: "middle",
                    field: 'isSolved',
                    title: '是否解决',
                }, {
                    align: 'center',
                    valign: "middle",
                    field: 'answerStatus',
                    title: '是否过期',
                }, {
                    align: 'center',
                    valign: "middle",
                    title: '操作',
                    width: 120,
                    formatter: function (value, row, index) {
                        return '<button  type="button" style="width: 100px" class="btn btn-danger btn-sm" onclick="addUserBlackModel(' + row.id + ')">删除<button style="width: 100px" type="button" class="btn btn-primary btn-sm" onclick="questionInfo(' + row.id + ')">查看&nbsp;&nbsp;&nbsp;详情</button>';
                    }
                },],
                //注册加载子表的事件。注意下这里的三个参数！
                onExpandRow: function (index, row, $detail) {
                    oTableInit.InitSubTable(index, row, $detail);
                }
            });
        };
        //得到查询的参数
        oTableInit.queryParams = function (params) {
            var temp = {   //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
                limit: params.limit,   //页面大小
                offset: params.offset,  //页码
                hospitalName: $("#hospitalName").val(),
                userName: $("#userName").val(),
                isSolved: $("#isSolved").val(),
                haveImg: $("#haveImg").val(),
                questionClass: $("#questionClass").val(),
                askDate: $("#startDate").val(),
                maxDate: $("#endDate").val(),
                questionMoney: $("#questionMoney").val(),
                questionContent: $("#questionContent").val(),
                answerStatus: $("#answerStatus").val()
                /*                departmentname: $("#txt_search_departmentname").val(),
                 statu: $("#txt_search_statu").val(),*/
            };
            return temp;
        };
        //初始化子表格(无线循环)
        oTableInit.InitSubTable = function (index, row, $detail) {
            var parentid = row.id;
            var cur_table = $detail.html('<table></table>').find('table');
            $(cur_table).bootstrapTable({
                url: '/fenda/findAnswer',
                method: 'get',
                queryParams: {questionId: parentid},
                ajaxOptions: {strParentID: parentid},
                clickToSelect: true,
                detailView: false,//父子表
                uniqueId: "",
                pageSize: 10,
                pageList: [10, 25],
                columns: [{
                    checkbox: true
                }, {
                    field: 'info',
                    title: '答案内容'
                }, {
                    field: 'master.name',
                    title: '专家姓名'
                }, {
                    field: 'praisedNum',
                    title: '点赞次数'
                }, {
                    field: 'reward',
                    title: '打赏钱数'
                }, {
                    align: 'center',
                    valign: "middle",
                    title: '操作',
                    formatter: function (value, row, index) {
                        return '<div><button  type="button" class="btn btn-danger" onclick="addUserBlack(' + row.master.id + ')">拉入黑名单</button></div>';
                    }
                },],
            });
        };
        return oTableInit;
    };
    var ButtonInit = function () {
        var oInit = new Object();
        var postdata = {};
        oInit.Init = function () {
            //初始化页面上面的按钮事件
        };
        return oInit;
    };
    //使checkbox居中对齐
    $("#hospital-table").on("load-success.bs.table", function (e, data) {
        $(".bs-checkbox").css("vertical-align", "middle");
    });
    //按钮对应的事件
    function sys_add() {
        $('#add-model').modal({
            keyboard: true
        });
    }
    function sys_delete() {
        var hospitals = $('#hospital-table').bootstrapTable('getAllSelections');
        var data = JSON.stringify(hospitals);
        $.ajax({
            url: "/fenda/deleteQuestion",
            data: {jsonData: data},
            method: "post",
            beforeSend: function () {
                $("#loadingModel").modal({backdrop: 'static', keyboard: false});
            },
            complete: function () {
                $("#loadingModel").modal('hide');
                $(".modal-backdrop").remove();
            },
            success: function (res) {
                $('#hospital-table').bootstrapTable('refresh', {
                    silent: true
                });
            }
        });
    }
    function sys_edite() {
    }
    //提交表单
    function add_from() {
        var hospitalParams = $("#hospital-form").serialize();
        $.ajax({
            url: '/fenda/addHospital',
            data: hospitalParams,
            beforeSend: function () {
                $("#loadingModel").modal({backdrop: 'static', keyboard: false});
            },
            complete: function () {
                $("#loadingModel").modal('hide');
                $(".modal-backdrop").remove();
            },
            success: function (res) {
                $('#hospital-table').bootstrapTable('refresh', {
                    silent: true
                });
            }
        });
    }
    //搜索
    function search() {
        $('#hospital-table').bootstrapTable("refresh", {
            silent: true
        });
    }
    //回车键触发搜索
    $("body").keydown(function () {
        if (event.keyCode == "13") {//keyCode=13是回车键
            $('#hospital-table').bootstrapTable("refresh", {
                silent: true
            });
        }
    });
    function openImg(questionId) {
        $.ajax({
            url: "/fenda/findQuestionUrl",
            data: {"questionId": questionId},
            success: function (res) {
                for (var i = 0; i < res.length; i++) {
                    $("#img-content").append("<img style='margin: 10px;width: 200px;height: 200px' src='" + res[i].imgURL + "'/>")
                }
                $('#img-model').modal({
                    keyboard: true
                });
            }
        });
    }
    //模态框关闭时执行
    $('#img-model').on('hidden.bs.modal', function () {
        $("#img-content").empty();
    })
    function addUserBlack() {
        $.ajax({
            url: "/fenda/deleteQuestion",
            data: {
                "questionId": modelQuestionId
            },
            type: "get",

            success: function (res) {
                $("#model2").modal('hide');
                $('#hospital-table').bootstrapTable("refresh", {
                    silent: true
                });
            },
            error: function (textStatus, errorThrown) {
            }
        });
    }
    function questionInfo(questionId) {
        answerQuestionId = questionId;
        $.ajax({
            url: "/fenda/questionInfo",
            type: "post",
            data: {
                "questionId": questionId
            },
            success: function (res) {
                if ((res.isSolved) == "是") {
                    $("#questionInfo-isSolved").html("已解决");
                } else {
                    $("#questionInfo-isSolved").html("未解决");
                }
                if (res.wxOrder.money == 0) {
                    $("#questionInfo-money").val("免费");
                } else {
                    $("#questionInfo-money").val(res.wxOrder.money);
                }
                $("#questionInfo-hospitalName").val(res.user.hospital.name);
                $("#questionInfo-userName").val(res.user.name);
                if ((res.info).length == 0 || (res.info) == "") {
                    $("#questionInfo-questionContent").val("无");
                } else {
                    $("#questionInfo-questionContent").val(res.info);
                }
                $("#questionInfo-questionClass").val(res.questionClass);
                $("#questionInfo-createDate").val(res.creatDate);
                if ((res.questionURLSet.length) == 0) {
                    $("#questionInfo-img").append("<p>无</P>");
                }
                $(res.questionURLSet).each(function (index, element) {
                    $("#questionInfo-img").append("<img src='" + element.imgURL + "' onclick=\"openQuestionImg('" + element.imgURL + "')\" style='width:50px;height:50px;margin:5px;'>");
                });
                if (res.answerList.length == 0) {
                    $("#answerInfo").append("<p style='align-items: center;'>暂时没有回答</P>")
                } else {
                    $(res.answerList).each(function (index, element1) {
                        if ((element1.info).length == 0 || (element1.info) == "" || (element1.info) == null) {
                            $("#answerInfo").append("" +
                                "<div style='margin-bottom: 30px;border:2px solid #000'>" +
                                "<div style='display:inline'><label>回答者姓名:</label> <input  class='questionInfo-input' value='" + element1.master.name + "'readonly></div>" +
                                "<div style='display: inline;'><label>回答时间:</label> <input  class='questionInfo-input' value='" + element1.creatDate + "'readonly></div>" +
                                "<div><label>点赞次数:</label> <input  class='questionInfo-input' value='" + element1.praiseUserSet.length + "'readonly></div>" +
                                "<div><label>获得积分:</label> <input  class='questionInfo-input' value='" + element1.masterScore.num + "'readonly></div>" +
                                "<div><label>回答内容:</label> <textArea  class='questionInfo-textArea' style='width: 550px;height: 100px' readonly> 无</textArea></div>" +
                                "<div ><label>图片:</label></div><div id='answerInfo-img" + element1.id + "'></div>" +
                                "<div> ");
                        } else {
                            $("#answerInfo").append("" +
                                "<div style='margin-bottom: 30px;border:2px solid #000'>" +
                                "<div style='display:inline'><label>回答者姓名:</label> <input  class='questionInfo-input' value='" + element1.master.name + "'readonly></div>" +
                                "<div style='display: inline;'><label>回答时间:</label> <input  class='questionInfo-input' value='" + element1.creatDate + "'readonly></div>" +
                                "<div><label>点赞次数:</label> <input  class='questionInfo-input' value='" + element1.praiseUserSet.length + "'readonly></div>" +
                                "<div><label>获得积分:</label> <input  class='questionInfo-input' value='" + element1.masterScore.num + "'readonly></div>" +
                                "<div><label>回答内容:</label> <textArea  class='questionInfo-textArea' style='width: 550px;height: 100px' readonly>" + element1.info + "</textArea></div>" +
                                "<div ><label>图片:</label></div><div id='answerInfo-img" + element1.id + "'></div>" +
                                "</div> ");
                        }
                        if ((element1.answerImgSet) == null || element1.answerImgSet.length == 0) {
                            $("#answerInfo-img" + element1.id).append("<p>无</p>  ");
                        } else {
                            $(element1.answerImgSet).each(function (index, element2) {
                                $("#answerInfo-img" + element1.id).append("<img src='" + element2.imgUrl + "' onclick=\"openAnswerImg('" + element2.id + "')\" style='width:50px;height:50px;margin:5px;'>");
                            });
                        }
                    });
                }
                $('#questionInfo-model').modal({
                    keyboard: true
                });
            }
        });
    }
    function closeQuestionInfoModel() {
        $("#questionInfo-img").empty();
        $("#answerInfo").empty();
        $('#questionInfo-model').modal('hide');
    }
    $('#questionInfo-model').on('hidden.bs.modal', function () {
        $("#questionInfo-img").empty();
        $("#answerInfo").empty();
    })
    function foundImg(imgUrl) {
        $("#lookImg-content").attr("src", imgUrl);
        $('#lookImg-model').modal({
            keyboard: true
        });
    }
    function addUserBlackModel(questionId) {
        modelQuestionId = questionId;
        $("#model2").modal({
            keyboard: true
        });
    }
    function modelhide2() {
        $('#hospital-table').bootstrapTable('refresh', {
            silent: true
        });
        $("#model2").modal('hide');
    }
    function openAnswerImg(answerImgId) {
        $.ajax({
            url: "/fenda/openAnswerImg",
            data: {
                imgId: answerImgId,
            },
            success: function (res) {
                $("#answerImg").attr('src', res);
                $("#answerImgModel").modal({
                    keyboard: true
                });
            }
        });
    }
    function openQuestionImg(questionImgUrl) {
        $("#questionImg").attr('src', questionImgUrl);
        $("#questionImgModel").modal({
            keyboard: true
        });
    }
    function closeQuestionImgModel() {
        $("#questionImgModel").modal('hide');
    }
    $("#questionImgModel").on("hidden.bs.modal", function () {
        $(document.body).addClass("modal-open");
    });
    $("#answerImgModel").on("hidden.bs.modal", function () {
        $(document.body).addClass("modal-open");
    });
    function answerQuestionModel() {
        $.ajax({
            url: "/fenda/checkQuestionAnswerStatus",
            data: {
                answerQuestionId: answerQuestionId,
            },
            success: function (res) {
                if (res == "error") {
                    $("#model4").modal({
                        keyboard: true
                    });
                }
                if (res == "right") {
                    $("#answerContentModel").modal({
                        keyboard: true
                    });
                }
            }
        });
    }
    function addAnswerContent() {
        $("#answerContentQuestion").val(answerQuestionId);
        $.ajax({
            url: '/fenda/addAnswerContent',
            type: 'POST',
            cache: false,
            data: new FormData($('#answerForm')[0]),
            processData: false,
            contentType: false,
            beforeSend: function () {
                $("#answerContentModel").modal('hide');
                $("#questionInfo-model").modal('hide');
                $("#model5").modal('hide');
                $("#loadingModel").modal({backdrop: 'static', keyboard: false});
            },
            complete: function () {
                $("#loadingModel").modal('hide');
                $(".modal-backdrop").remove();
            },
        }).done(function (res) {

        }).fail(function (res) {
        });
    }
    function addAnswerContentModel() {
        $("#model5").modal({
            keyboard: true
        });
    }
    $("#model4").on("hidden.bs.modal", function () {
        $(document.body).addClass("modal-open");
    });
    $("#answerContentModel").on("hidden.bs.modal", function () {
        $(document.body).addClass("modal-open");
    });
</script>
</body>
</html>
